home *** CD-ROM | disk | FTP | other *** search
- Path: news.uh.edu!usenet
- From: Sensarn <txs53132@bayou.uh.edu>
- Newsgroups: comp.lang.c++
- Subject: Re: C++ Graphics
- Date: 10 Feb 1996 04:12:59 GMT
- Organization: AEtna Insurance Agency
- Message-ID: <4fh60b$hc9@masala.cc.uh.edu>
- References: <4fe99q$s2s@newsbf02.news.aol.com>
- NNTP-Posting-Host: sip-14122.public-dialups.uh.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.1 (Windows; U; 16bit)
-
- First of all, you need to access the video buffer. This is located in
- segment A000. I would strongly suggest starting with mode 13h. Here is
- how to call it:
-
- //via BIOS
- union REGS inregs, outregs;
- inregs.x.ax=0x13;
- int86(0x10,&inregs,&outregs);
-
- //via inline assembler
- asm {
- mov ax,0x13
- int 0x10
- }
-
- To set a pointer that can allow ease of video access, use this:
-
- unsigned char far *video_buffer=(unsigned char far *)0xA0000000;
-
- You now have a FAR pointer to A000:0000h, the beginning of the video
- buffer. To plot a pixel, you use this formula:
-
- video_buffer[y*320+x]=color;
-
- Use binary shifting for speed:
-
- video_buffer[(y<<8)+(y<<6)+x]=color;
-
- To create a virtual screen (double buffer), use this declaration and
- initialization:
-
- unsigned char *double_buffer=(unsigned char far *)far_malloc(64001);
-
- You have now allocated a full-screen double buffer. To display it, you
- can either use memcpy, or pure assembly (assembly is recommended because
- it's faster):
-
- asm {
- les di,video_buffer
- lds si,double_buffer
- cld
- mov cx,32000
- rep movsw
- }
-
- That example simply stores the segment and offset of video_buffer into
- ES:DI (extra segment and destiny index -- destination) and the segment
- and offset of double_buffer into DS:SI (data segment and source index --
- source). It clears the direction flag (just in case we're facing
- backward -- we don't want that) and writes 32000 words (a full screen)
- from the double buffer to the video buffer. Wow! You can copy the
- screen to the double buffer by storing double_buffer in ES:DI and
- video_buffer in DS:SI.
- If you have any specific questions, feel free to ask them.
-
- --
- |\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\|
- Steven Sensarn -- txs53132@bayou.uh.edu
- |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
-
-
-